from flask import Blueprint, make_response, jsonify
from flask_restful import Resource, abort
from sqlalchemy import text

import time


from apps.ext import db, cache

# from manage import limiter
from setting import current_limiting, login_required

test = Blueprint('test', __name__)

class hei(Resource):
    @current_limiting(6)
    # @login_required
    def get(self):
        print(666)
        print('进入了销毁发送消息')

        aaa = cache.cache
        print(aaa._cache.get('asdada',None))
        # if aaa._cache.get('asdada') is None:
        #     print('缓存了')
        #     cache.set('asdada', time.time(), timeout=2)
        # print(cache.get('asdada'))
        # print(aaa._cache.has('asdada'))

        return make_response(jsonify({'msg':"123"}), 201)
        # data = SQLHelper().fetchallListJson("select top 10000 PRD_NO,SNM,IDX1,IDX2,UT,UT1,DFU_UT,NAME,SPC,CCC,KND,SPC_TAX,PK2_UT,PK2_QTY,PK3_UT from prdt")
        # return make_response(jsonify(data), 201)
    def post(self):
        #post请求走这里
        return {'msg':'hell world'}
# LOC = """
# fact = 1
# # for i in range(5):
# #     fact = fact * i
# #     print(fact)
# print(fact)
# """
class yaLitest(Resource):
    def get(self):
        fact = 1
        for i in range(5):
            fact = fact * i
            print(fact)
        LOC = """
fact = 1
for i in range(5):
    fact = fact * i+1
    print(fact)
print(fact)
        """
        exec(LOC)
        return make_response(jsonify({'msg':'hell world'}), 201)


